package com.rfid.api;

import java.util.ArrayList;
import java.util.List;


public class MonitorLogHelper {
    //static LogObserver Observer;
    private static List<LogObserver> observers =new ArrayList<>();
    public  static  MonitorLogHelper Log(){return  new MonitorLogHelper();}
    public  void  SetLogEvent(LogObserver observer)
    {
        observers.add(observer);
        //       //this.Observer=observer;
    }
    public  void DeleteLogEevent(LogObserver observer)
    {
        int i = observers.indexOf(observer);
        if(i>=0){
            observers.remove(observer);
        }
    }
    public  void Clear()
    {
        for(int i=0;i<observers.size();i++){
            LogObserver o=(LogObserver)observers.get(i);
            o.Clear();
        }

    }
    public  void WriterLog(String text)
    {
        for(int i=0;i<observers.size();i++){
            LogObserver o=(LogObserver)observers.get(i);
            o.Log(text);
        }
    }

    public  interface LogObserver {
        void Log(String o);
        void Clear();
    }
}
